/**
 * Created by SCR on 2017/8/1.
 */

var mongoose = require('../mongooseModel');

var mongodb = require('../mongoDB');
var ObjectId = require('mongodb').ObjectID;
var ModelBase = require('../modelBase');

function Network(network){
    if(network){
        for(var key in network){
            this[key] = network[key];
        }
        if(!network._id){
            this._id = new ObjectId();
        }
    }
    else{
        this._id = new ObjectId();
        this.modelServices = [];
        this.dataServices = [];
        this.networkInfo = [];
        this.time = (new Date()).getTime();
    }
}

Network.__proto__ = ModelBase;
module.exports = Network;

var networkSchema = new mongoose.Schema({
    modelServices:mongoose.Schema.Types.Mixed,
    dataServices:mongoose.Schema.Types.Mixed,
    networkInfo:mongoose.Schema.Types.Mixed,
    time:Number
},{collection:'Network'});

var networkModel = mongoose.model('Network',networkSchema);
Network.baseModel = networkModel;
Network.modelName = 'Network';
